package com.kstudio.videocapture.util.bmpcache;

import android.graphics.Bitmap;
import android.util.LruCache;

public class KLoadBitmapCacheMemory {

    private LruCache<String, Bitmap> mCache;

    public KLoadBitmapCacheMemory(int maxSize) {
        mCache =  new LruCache<String, Bitmap>(maxSize) {
            @Override
            protected int sizeOf(String key, Bitmap bitmap) {
                // The cache size will be measured in bytes
                return bitmap.getByteCount();
            }
        };
    }

    public void add(String key, Bitmap bitmap) {
        if(bitmap == null)  return;

        mCache.put(key, bitmap);
    }

    public Bitmap get(String key) {
        return mCache.get(key);
    }
}
